package com.cc.service.impl;


import com.cc.entity.Employees;
import com.cc.mapper.EmployeesMapper;
import com.cc.service.EmployeesService;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * @author hct
 * @description 针对表【employees】的数据库操作Service实现
 * @createDate 2024-10-21 08:45:38
 */
@Service
public class EmployeesServiceImpl implements EmployeesService {

    @Autowired
    EmployeesMapper employeesMapper;

    @Override
    public int save(Employees employees) {
        return employeesMapper.insertBatch(Arrays.asList(employees));
    }

    @Override
    public int update(Employees employees) {
        return employeesMapper.updateSelective(employees);
    }

    @Override
    public int delete(Integer employeeId) {
        return employeesMapper.delByEmployeeId(employeeId);
    }

    @Override
    public Employees selectAllByLoginNameAndPassword(String loginName, String password) {
        return employeesMapper.selectAllByLoginNameAndPassword(loginName, password);
    }

    @Override
    public PageInfo<Employees> getPage(String empName, String phoneNumber, Integer pageNum) {
        PageHelper.startPage(pageNum, 5);
        List<Employees> employeeList = employeesMapper.selectAllByEmpNameAndPhoneNumber(empName, phoneNumber);
        PageInfo<Employees> pageInfo = new PageInfo<>(employeeList);
        return pageInfo;
    }

    @Override
    public Employees queryById(Integer id) {
        return employeesMapper.searchAllByEmployeeId(id);
    }
}




